package com.jeesite.modules.jydq.entity;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.sys.entity.User;
import lombok.Getter;
import lombok.Setter;

/**
 * 商品评论表Entity
 * @author dong
 * @version 2025-03-20
 */
@Table(name="jydq_product_comment", alias="a", label="商品评论表信息", columns={
		@Column(name="id", attrName="id", label="编号", isPK=true),
		@Column(name="product_id", attrName="productId", label="商品ID"),
		@Column(name="content", attrName="content", label="评论内容"),
		@Column(name="rating", attrName="rating", label="评分 1-5分", isUpdateForce=true),
		@Column(name="images", attrName="images", label="图片"),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false, isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false, isQuery=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注", queryType=QueryType.LIKE),
	}, joinTable={
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= User.class, alias="cuser",
				on="cuser.user_code=a.create_by", attrName="this",
				columns={
						@Column(name="user_name", attrName = "createName", label="用户名", queryType=QueryType.LIKE),
				}),
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= JydqProduct.class, alias="product",
				on="product.id=a.product_id", attrName="this",
				columns={
						@Column(name="name", attrName = "productName", label="商品名称", queryType=QueryType.LIKE),
				}),
	}, orderBy="a.update_date DESC"
)
public class JydqProductComment extends DataEntity<JydqProductComment> {
	
	private static final long serialVersionUID = 1L;
	private String productId;		// 商品ID
	private String content;		// 评论内容
	private Integer rating;		// 评分 1-5分
	private String images;		// 图片
	//非持久化字段
	@Getter
	@Setter
	private String createName;		// 用户名
	@Getter
	@Setter
	private String productName;		// 商品名称

	public JydqProductComment() {
		this(null);
	}
	
	public JydqProductComment(String id){
		super(id);
	}
	
	@NotBlank(message="商品ID不能为空")
	@Size(min=0, max=64, message="商品ID长度不能超过 64 个字符")
	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}
	
	@NotBlank(message="评论内容不能为空")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	public Integer getRating() {
		return rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}
	
	public String getImages() {
		return images;
	}

	public void setImages(String images) {
		this.images = images;
	}
	
}